package cn.czh0123.job;

import cn.czh0123.redis.service.IWallpaperOperateRedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Slf4j
@Component
@EnableScheduling
public class DataMigrationJob {

    @Resource
    private IWallpaperOperateRedisService wallpaperOperateRedisService;

    @Scheduled(fixedRate = 2 * 60 * 60 * 1000, initialDelay = 2 * 60 * 60 * 1000)
    @Transactional
    public void migrateWallpaperRecord() {
        log.info("壁纸操作记录持久化开始！");
        wallpaperOperateRedisService.saveWallpaperOperateRecord();
        log.info("壁纸操作记录持久化结束！");
    }
}